package com.elinkway.infinitemovies.http.api;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Base64;

import com.elinkway.infinitemovies.application.MoviesApplication;
import com.elinkway.infinitemovies.bean.ChannelDetailList;
import com.elinkway.infinitemovies.bean.PostCloudErrorBean;
import com.elinkway.infinitemovies.bean.UploadPlayRecordBean;
import com.elinkway.infinitemovies.bigdata.BigDataConstants;
import com.elinkway.infinitemovies.bigdata.BigDataUtils;
import com.elinkway.infinitemovies.config.SettingManage;
import com.elinkway.infinitemovies.dao.PreferencesManager;
import com.elinkway.infinitemovies.http.parser.ChannelDetailListParser;
import com.elinkway.infinitemovies.ui.activity.LoginActivity;
import com.elinkway.infinitemovies.ui.activity.play.PlayDecodeMananger;
import com.elinkway.infinitemovies.utils.HostUtil;
import com.elinkway.infinitemovies.utils.IdUtils;
import com.elinkway.infinitemovies.utils.LiteAppManager;
import com.elinkway.infinitemovies.utils.LogUtils;
import com.elinkway.infinitemovies.utils.MD5Utils;
import com.elinkway.infinitemovies.utils.MoviesConstant;
import com.elinkway.infinitemovies.utils.MoviesUtils;
import com.elinkway.infinitemovies.utils.MyLocationManager;
import com.elinkway.infinitemovies.utils.SharePreferenceManager;
import com.elinkway.infinitemovies.utils.SignChecker;
import com.elinkway.infinitemovies.utils.UUIDFactory;
import com.elinkway.infinitemovies.utils.Utils;
import com.google.gson.Gson;
import com.lvideo.http.bean.LVideoBaseBean;
import com.lvideo.http.bean.LVideoDataHull;
import com.lvideo.http.bean.LVideoRequestHeader;
import com.lvideo.http.impl.LVideoHttpBaseParameter;
import com.lvideo.http.impl.LVideoHttpParameter;
import com.lvideo.http.impl.LVideoHttpTool;
import com.lvideo.http.parse.LVideoBaseParser;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public class MoviesHttpApi {

    private final static String TAG = "MoviesHttpApi";

    public static boolean TEST = false;

    public final static String TEST_HOST = "testHost";

    // ad model
    public static final String LAUNCH_MODEL = "480*800";
    public static final String APP_MODEL = "600*100";

    /**
     * 首页右下角 广告位
     */
    public static final String HOME_SHAKE = "shakeHome";
    public static final String DETAIL_SHAKE = "shakeDetail";
    public static final String DETAIL_MARQUE = "detailMarque";

    /**
     * 首页头部焦点图banner
     */
    public static final String FOCUS_BANNER = "focusBanner";
    /**
     * 首页中间的横幅banner
     */
    public static final String HOME_BANNER = "homeBanner";
    /**
     * 详情页 广告位
     */
    public static final String DETAIL = "detail";
    /**
     * 下载 广告位
     */
    public static final String DOWNLOAD = "download";
    /**
     * 暂停 广告位
     */
    public static final String PAUSE = "pause";
    /**
     * 开启app 广告标识位 原apiStart接口
     */
    public static final String LAUNCH = "launch";
    /**
     * 退出app 广告标识位  原apiStart接口
     */
    public static final String QUIT = "quit";

    /**
     * 贴片广告
     */
    public static final String ATTACH = "attach";

    /**
     * 公共参数
     */
    public static final String PLATFORM;
    public static final String VERSION;
    public static final String CHANNEL;
    public static final String DEVICEID;
    public static final String TS = "ts";
    public static final String SIG = "sig";
    public static final String PN = "pn";
    public static final String TAGS = "tags";

    /**
     * 升级接口所用的SYSTEM 参数
     */
    public static final String PLATFORM_IN_UPGRADE = IdUtils.PLATFORM_IN_UPGRADE;

    public static final String CODE = "346e5b9d1bd97036";

    public static final String PLATTYPE_VAULE = "aphone";

    public static final String NEW_API_VERSION = "2";

    public static boolean isCompleteUrl;

    public static final int APIJIEXI_TAG_1001 = 1001;

    public static final String USER_LOGIN_APPID = IdUtils.USER_LOGIN_APPID;

    public static final String USER_PRODUCT_ID = IdUtils.USER_PRODUCT_ID;

    /**
     * 首页推荐模块数据
     */
    private static final String GET_MAINPAGE_RECOMMEND_DATA_URL = "kuaikan/apipage_json.so";
    // private static final String GET_MAINPAGE_RECOMMEND_DATA_URL =
    // "LVideoNewOptimize/pageApi";

    /**
     * 专题列表页
     */
    private static final String GET_TOPIC_DATA_URL = "api/v2/theme/list";
    // private static final String GET_TOPIC_DATA_URL =
    // "LVideoNewOptimize/themeListApi";

    /**
     * 专题详情页
     */
    // request TopicDetail api
    private static final String GET_TOPIC_DETAIL_URL = "api/v2/theme/detail";
    // private static final String GET_TOPIC_DETAIL_URL =
    // "LVideoNewOptimize/themeApi";

    static {
        VERSION = MoviesUtils.getClientVersionName();
        CHANNEL = MoviesUtils.getClientChannel();
        PLATFORM = PLATFORM_IN_UPGRADE + CHANNEL;
        DEVICEID = MoviesUtils.getmDeviceId();
        LogUtils.e("wym", "httpApi init DEVICEID is " + DEVICEID);
    }

    public interface PUBLIC_PARAMETERS {
        String PLATFORM_KEY = "platform";
        String CODE_KEY = "code";
        String VERSION_KEY = "version";
        String PLATTYPE_KEY = "plattype";
        String DEFINITION = "definition";
        String LOCATION = "city";
        String IP = "ip";
        String LC = "lc";
        String API_VERSION = "apiversion";
        String SARRS = "sarrs";
        String OS = "os";
        String DEVICE = "device";
        String CHANNEL = "channel";
        String AUID = "auid";
        String VERSION = "version";
        String ILU = "ilu";
        String NT = "nt";
        String CTIME = "ctime";
        String IMEI = "imei";
        String MAC = "mac";
    }

    private interface TOPIC_DATA_PARAMETERS {
        String PAGE_KEY = "pageindex";
        String PAGE_SIZE_KEY = "pagesize";
    }

    private interface SUBSCRIPTION_PARAMETERS {
        String SUBSCRIPTION_AID = "aid";
        String SUBSCRIPTION_SCOPE = "scope";
        String SUBSCRIPTION_OFFSET = "offset";
        String SUBSCRIPTION_LIMIT = "limit";
    }

    private static final String GET_CHANNEL_DETAIL_LIST_URL = "kuaikan/apilistnew_json.so";

    private static interface CHANNEL_DETAIL_LIST_PARAMETERS {
        public String ORDERBY_KEY = "orderby";
        public String PAGEINDEX_KEY = "pageindex";
        public String SUBCATEGORY_KEY = "subcategory";
        public String PAGESIZE_KEY = "pagesize";
        public String AREA_KEY = "area";
        public String VT_KEY = "vt";
        public String YEAR_KEY = "year";
    }

    private static final String GET_CHANNEL_PIECE = "/kuaikan/apichannelnew_json.so";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestChannelPiece(
            LVideoBaseParser<T, D> parser) {
        String url = getStaticHead() + GET_CHANNEL_PIECE;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    private static final String GET_SUBSCRIPTION_ALBUM_URL = "kuaikan/apisubscription_album.so";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestSubscriptionAlbum(
            LVideoBaseParser<T, D> parser, String aid,
            String offset, String limit) {
        String url = getStaticHead() + GET_SUBSCRIPTION_ALBUM_URL;
        Bundle params = new Bundle();
        params.putString(SUBSCRIPTION_PARAMETERS.SUBSCRIPTION_AID, aid);
        params.putString(SUBSCRIPTION_PARAMETERS.SUBSCRIPTION_OFFSET, offset);
        params.putString(SUBSCRIPTION_PARAMETERS.SUBSCRIPTION_LIMIT, limit);
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }


    private static final String GET_SUBSCRIPTION_MAIN_URL = "kuaikan/apisubscription_json.so";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestSubscription(
            LVideoBaseParser<T, D> parser, String scope,
            String offset, String limit) {
        String url = getStaticHead() + GET_SUBSCRIPTION_MAIN_URL;
        Bundle params = new Bundle();
        params.putString(SUBSCRIPTION_PARAMETERS.SUBSCRIPTION_SCOPE, scope);
        params.putString(SUBSCRIPTION_PARAMETERS.SUBSCRIPTION_OFFSET, offset);
        params.putString(SUBSCRIPTION_PARAMETERS.SUBSCRIPTION_LIMIT, limit);
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> postCloudError(
            LVideoBaseParser<T, D> parser, PostCloudErrorBean postCloudErrorBean) {
        isCompleteUrl = true;
        String url = "http://clientreport.lecloud.com/api/report";
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, new Bundle(), LVideoHttpParameter.Type.POST, parser, -1);
        Gson gson = new Gson();
        httpParameter.setPostJsonData(gson.toJson(postCloudErrorBean));
        LogUtils.e("", "post Json " + gson.toJson(postCloudErrorBean));
        return request(httpParameter);
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestCloudError(
            LVideoBaseParser<T, D> parser, String url) {
        LogUtils.e("", "requestCloudError " + url);
        isCompleteUrl = true;
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, new Bundle(), LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestPublicIpAddress(
            LVideoBaseParser<T, D> parser) {
        LogUtils.e("", "request ip middle");
        String url = "http://1212.ip138.com/ic.asp";
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, new Bundle(), LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestChannelDetail(
            LVideoBaseParser<T, D> parser, String orderby, int pageindex,
            String subcategory, int pagesize, String area, String vt,
            String year) {
        String url = getStaticHead() + GET_CHANNEL_DETAIL_LIST_URL;
        Bundle params = new Bundle();
        params.putString("uuid", MoviesConstant.UUID);
        addCommonParams(params);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        if (!"".equals(orderby)) {
            params.putString(CHANNEL_DETAIL_LIST_PARAMETERS.ORDERBY_KEY,
                    String.valueOf(orderby));
        }
        params.putString(CHANNEL_DETAIL_LIST_PARAMETERS.PAGEINDEX_KEY,
                String.valueOf(pageindex));
        if (!"".equals(subcategory)) {
            params.putString(CHANNEL_DETAIL_LIST_PARAMETERS.SUBCATEGORY_KEY,
                    String.valueOf(subcategory));
        }
        params.putString(CHANNEL_DETAIL_LIST_PARAMETERS.PAGESIZE_KEY,
                String.valueOf(pagesize));

        if (!"".equals(area)) {
            params.putString(CHANNEL_DETAIL_LIST_PARAMETERS.AREA_KEY,
                    String.valueOf(area));
        }

        params.putString(CHANNEL_DETAIL_LIST_PARAMETERS.VT_KEY,
                String.valueOf(vt));

        if (!"".equals(year)) {
            params.putString(CHANNEL_DETAIL_LIST_PARAMETERS.YEAR_KEY,
                    String.valueOf(year));
        }
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    // request all with no filter
    public static LVideoDataHull<ChannelDetailList> requestChannelDetail(
            ChannelDetailListParser channelDetailListParser, int requestPage,
            int channelDetailListRequestSize, String vt) {
        return requestChannelDetail(channelDetailListParser, "", requestPage,
                "", channelDetailListRequestSize, "", vt, "");
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestTopicData(
            int nextpage, int topicRequestSize, LVideoBaseParser<T, D> parser) {

        // String url = "http://111.206.210.48:7070/" + GET_TOPIC_DATA_URL;
        String url = getStaticHead() + GET_TOPIC_DATA_URL;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString("uuid", MoviesConstant.UUID);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString(TOPIC_DATA_PARAMETERS.PAGE_KEY,
                String.valueOf(nextpage));
        params.putString(TOPIC_DATA_PARAMETERS.PAGE_SIZE_KEY,
                String.valueOf(topicRequestSize));
        params.putString("vt", "-1");
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));

        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        LogUtils.i("Topic_List_Request", params.toString());
        return request(httpParameter);

    }

    /**
     * 二级分类
     **/
    private static final String GET_SIFT_LIST_URL = "kuaikan/apisubcategory_json.so";

    private static interface SIFT_LIST_PARAMETERS {
        public String VT_KEY = "vt";
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestSiftList(
            LVideoBaseParser<T, D> parser, String vt) {
        String url = getStaticHead() + GET_SIFT_LIST_URL;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString("uuid", MoviesConstant.UUID);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString(SIFT_LIST_PARAMETERS.VT_KEY, vt);
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));

        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);

        return request(httpParameter);
    }

    private static interface MAINPAGE_RECOMMEND_DATA_PARAMETERS {
        public String PAGE_KEY = "page";
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestMainPageData(
            LVideoBaseParser<T, D> parser, String page) {
        String url = getStaticHead() + GET_MAINPAGE_RECOMMEND_DATA_URL;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString(MAINPAGE_RECOMMEND_DATA_PARAMETERS.PAGE_KEY, page);
        params.putString("uuid", MoviesConstant.UUID);
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);

        return request(httpParameter);
    }

    private static interface RECOMM_DATA_PARAMETERS {
        public String RECOMMEND_KEY = "recommend";
    }

    /**
     * 排行榜首页
     **/
    private static final String GET_HOME_RANK_DATA_URL = "kuaikan/apirank_json.so";

    private static interface RANK_HOME_DATA_PARAMETERS {
        public String RECOMMEND_KEY = "rank";
        public String RECORD_KEY = "record";
    }

    private static interface RANK_HOME_DATA_VALUES {
        public String MOVIE = "m_rank_movie";
        public String TV = "m_rank_tv";
        public String ZONGYI = "m_rank_zongyi";
        public String CARTOON = "m_rank_cartoon";
        public String[] RECOMMEND_VALUE = {MOVIE, TV, CARTOON, ZONGYI};
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestRankHomeData(
            LVideoBaseParser<T, D> parser, String[] records) {

        String url = getStaticHead() + GET_HOME_RANK_DATA_URL;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString("uuid", MoviesConstant.UUID);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString(RANK_HOME_DATA_PARAMETERS.RECOMMEND_KEY,
                TextUtils.join(",", RANK_HOME_DATA_VALUES.RECOMMEND_VALUE));
        params.putString(RANK_HOME_DATA_PARAMETERS.RECORD_KEY,
                TextUtils.join(",", records));
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);

        return request(httpParameter);

    }

    /**
     * 排行榜详情页
     **/
    private static final String GET_RANK_DATA_URL = "kuaikan/apirank_json.so";

    private static interface RANK_DATA_PARAMETERS {
        public String RECOMMEND_KEY = "rank";
    }

    private static interface RANK_DATA_VALUES {
        public String MOVIE = "m_rank_movie";
        public String TV = "m_rank_tv";
        public String ZONGYI = "m_rank_zongyi";
        public String CARTOON = "m_rank_cartoon";
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestRankListData(
            LVideoBaseParser<T, D> parser, String vt) {
        String value = "";
        if (vt.equals(MoviesConstant.VT_MOVIE)) {
            value = RANK_DATA_VALUES.MOVIE;
        } else if (vt.equals(MoviesConstant.VT_TV)) {
            value = RANK_DATA_VALUES.TV;
        } else if (vt.equals(MoviesConstant.VT_CARTOON)) {
            value = RANK_DATA_VALUES.CARTOON;
        } else if (vt.equals(MoviesConstant.VT_ZONGYI)) {
            value = RANK_DATA_VALUES.ZONGYI;
        }

        String url = getStaticHead() + GET_RANK_DATA_URL;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString("uuid", MoviesConstant.UUID);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString(RANK_DATA_PARAMETERS.RECOMMEND_KEY, value);
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);

        return request(httpParameter);
        // TODO Auto-generated method stub

    }

    // request SearchResult api
    private static final String GET_SEARCH_RESULT_URL = "kuaikan/apisearch_json.so";

    private static interface SEARCH_RESULT_PARAMETERS {
        public String PAGEINDEX_KEY = "pageindex";
        public String WD_KEY = "wd";
        public String PAGESIZE_KEY = "pagesize";
        public String VT_KEY = "vt";
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestSearchResult(
            LVideoBaseParser<T, D> parser, int pageindex, String wd,
            int pagesize, String vt) {
        String url = getStaticHead() + GET_SEARCH_RESULT_URL;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString("uuid", MoviesConstant.UUID);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString(SEARCH_RESULT_PARAMETERS.PAGEINDEX_KEY,
                String.valueOf(pageindex));
        // wd = Utils.replaceBlank(wd);
        if (!TextUtils.isEmpty(wd)) {
            wd = wd.trim();
        }
        params.putString(SEARCH_RESULT_PARAMETERS.WD_KEY, wd);
        params.putString(SEARCH_RESULT_PARAMETERS.PAGESIZE_KEY,
                String.valueOf(pagesize));
        params.putString(SEARCH_RESULT_PARAMETERS.VT_KEY, vt);
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    // request SearchSuggest api
    private static final String GET_SEARCH_SUGGEST_URL = "kuaikan/apisuggest_json.so";

    private static interface SEARCH_SUGGEST_PARAMETERS {
        public String WD_KEY = "wd";
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestSearchSuggest(
            LVideoBaseParser<T, D> parser, String wd) {
        String url = getStaticHead() + GET_SEARCH_SUGGEST_URL;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString("uuid", MoviesConstant.UUID);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString(SEARCH_SUGGEST_PARAMETERS.WD_KEY, wd);
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    private static final String GET_SEARCH_HOT_URL = "kuaikan/apirecommend_json.so";

    private static interface SEARCH_HOT_VALUES {
        public String HOT = "REC_SEARCH_TOP";
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestSearchHotData(
            LVideoBaseParser<T, D> parser) {

        String url = getStaticHead() + GET_SEARCH_HOT_URL;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString("uuid", MoviesConstant.UUID);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString(RECOMM_DATA_PARAMETERS.RECOMMEND_KEY,
                SEARCH_HOT_VALUES.HOT);
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));

        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);

        return request(httpParameter);
        // TODO Auto-generated method stub

    }

    private static final String GET_HOT_DOWNLOAD_URL = "kuaikan/apihotdownload_json.so";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestHotDownloadData(
            LVideoBaseParser<T, D> parser) {

        String url = getStaticHead() + GET_HOT_DOWNLOAD_URL;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));

        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);

        return request(httpParameter);
    }

    private static interface TOPIC_DETAIL_PARAMETERS {
        public String PAGEINDEX_KEY = "pageindex";
        public String PAGESIZE_KEY = "pagesize";
        public String THEMEID_KEY = "themeid";
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestTopicDetail(
            LVideoBaseParser<T, D> parser, int pageIndex, int pageSize, String themeId) {
        String url = getStaticHead() + GET_TOPIC_DETAIL_URL;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString(TOPIC_DETAIL_PARAMETERS.THEMEID_KEY, themeId);
        params.putString(TOPIC_DETAIL_PARAMETERS.PAGEINDEX_KEY, String.valueOf(pageIndex));
        params.putString(TOPIC_DETAIL_PARAMETERS.PAGESIZE_KEY, String.valueOf(pageSize));
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    // request Feedback api
    private static final String GET_FEEDBACK_URL = "api/mobileapi/apifeedback_json.so";

    private static interface FEEDBACK_PARAMETERS {
        public String CONTENT_KEY = "content";
        public String CONTACTWAY_KEY = "contactway";
    }

    @Deprecated
    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> postFeedback(
            LVideoBaseParser<T, D> parser, String content, String contactway) {
        String url = getStaticHead() + GET_FEEDBACK_URL;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString(FEEDBACK_PARAMETERS.CONTENT_KEY, content);
        params.putString(FEEDBACK_PARAMETERS.CONTACTWAY_KEY, contactway);
        params.putString("uuid", MoviesConstant.UUID);
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    private static interface VIDEO_DATA_PARAMETERS {
        public String AID_KEY = "aid";
        public String SRC_KEY = "src";
    }

    // request VideoData api
    // private static final String GET_VIDEO_DATA_URL =
    // "kuaikan/apidetail_json.so";
    private static final String GET_VIDEO_DATA_URL = "kuaikan/apisimpledetail_json.so";


    /**
     * 视频详情信息
     *
     * @param parser
     * @param aid
     * @param src
     * @param <T>
     * @param <D>
     * @return
     */
    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestVideoData(
            LVideoBaseParser<T, D> parser, String aid, String src) {
        String url = getStaticHead() + GET_VIDEO_DATA_URL;
        // if(MoviesConstant.DEBUG){
        // url = "http://10.154.252.65:7070/"+ GET_VIDEO_DATA_URL;
        // }
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString(VIDEO_DATA_PARAMETERS.AID_KEY, aid);
        params.putString("uuid", MoviesConstant.UUID);
        params.putString(PUBLIC_PARAMETERS.DEFINITION, "1");
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        if ("search".equals(src)) {
            params.putString("referer", "search");
        }
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    private static interface PLAY_SRC_LIST_PARAMETERS {
        public String SITE_KEY = "site";
        public String AID_KEY = "aid";
        public String PAGESIZE_KEY = "pagesize";
        public String PAGEINDEX_KEY = "pageindex";
    }

    // request PlaySrcList api
    // private static final String GET_PLAY_SRC_LIST_URL =
    // "kuaikan/apiwebsite_json.so";
    private static final String GET_VIDEO_LIST_URL = "api/v2/detail/website";

    /**
     * 获取详情页站点源列表(包括播放下载原始url等数据)
     *
     * @param parser
     * @param site
     * @param aid
     * @param pageIndex
     * @param pageSize
     * @return
     */
    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestVideoList(
            LVideoBaseParser<T, D> parser, String site, String aid,
            int pageIndex, int pageSize) {
        String url = getStaticHead() + GET_VIDEO_LIST_URL;
//        String url = "http://10.176.28.235:7070/" + GET_VIDEO_LIST_URL;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString(PLAY_SRC_LIST_PARAMETERS.SITE_KEY, site);
        params.putString(PLAY_SRC_LIST_PARAMETERS.AID_KEY, aid);
        params.putString(PLAY_SRC_LIST_PARAMETERS.PAGESIZE_KEY,
                String.valueOf(pageSize));
        params.putString(PLAY_SRC_LIST_PARAMETERS.PAGEINDEX_KEY,
                String.valueOf(pageIndex));
        params.putString("uuid", MoviesConstant.UUID);
        params.putString(PUBLIC_PARAMETERS.DEFINITION, "1");
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestNewVideoList(
            LVideoBaseParser<T, D> parser, String site, String aid,
            int pageIndex) {
        String url = getStaticHead() + GET_VIDEO_LIST_URL;
//        String url = "http://10.176.28.235:7070/" + GET_VIDEO_LIST_URL;
        Bundle params = new Bundle();
        params.putString(PLAY_SRC_LIST_PARAMETERS.SITE_KEY, site);
        params.putString(PLAY_SRC_LIST_PARAMETERS.AID_KEY, aid);
        params.putString(PUBLIC_PARAMETERS.PLATFORM_KEY, PLATFORM);
        params.putString(PN, String.valueOf(pageIndex));
        params.putString(PUBLIC_PARAMETERS.LOCATION,SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    // request PlaySrc api
    private static final String GET_PLAY_SRC_URL = "kuaikan/apiwebsite_json.so";

    // requset albumupdateinfolisturl
    private static final String GET_ALBUM_UPDATE_INFO_URL = "kuaikan/apialbuminfo_json.so";

    // qinguoli
    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestAlbumUpdateInfoList(
            LVideoBaseParser<T, D> parser, String aid) {
        String url = getStaticHead() + GET_ALBUM_UPDATE_INFO_URL;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString("uuid", MoviesConstant.UUID);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        // params.putString(PLAY_SRC_LIST_PARAMETERS.SRC_KEY, src);
        params.putString(PLAY_SRC_LIST_PARAMETERS.AID_KEY, aid);
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));

        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    private static interface PLAY_SRC_PARAMETERS {
        public String SRC_KEY = "src";
        public String SITE_KEY = "site";
        public String AID_KEY = "aid";
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestPlaySrc(
            LVideoBaseParser<T, D> parser, String src, String site, String aid) {
        String url = getStaticHead() + GET_PLAY_SRC_URL;
        // if(MoviesConstant.DEBUG){
        // url = "http://10.154.28.65:7070/"+ GET_PLAY_SRC_URL;
        // }
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString(PLAY_SRC_PARAMETERS.SRC_KEY, src);
        params.putString(PLAY_SRC_PARAMETERS.SITE_KEY, site);
        params.putString(PLAY_SRC_PARAMETERS.AID_KEY, aid);
        params.putString("uuid", MoviesConstant.UUID);
        params.putString(PUBLIC_PARAMETERS.DEFINITION, "1");
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    private static interface RELATION_PARAMETERS {
        public String SRC_KEY = "src";
        public String CID_KEY = "cid";
        public String AID_KEY = "aid";
        public String NUM_KEY = "num";
    }

    private static final String GET_RELATION_URL = "api/v2/rec/related";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestRelation(
            LVideoBaseParser<T, D> parser, String src, String cid, String aid) {
        String url = getStaticHead() + GET_RELATION_URL;

        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString(RELATION_PARAMETERS.SRC_KEY, src);
        params.putString(RELATION_PARAMETERS.CID_KEY, cid);
        params.putString(RELATION_PARAMETERS.AID_KEY, aid);
        params.putString("unique_id", MoviesConstant.UUID);
        params.putString(RELATION_PARAMETERS.NUM_KEY,
                String.valueOf(MoviesConstant.DETAIL_RELATION_NUM));
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    public static String getStaticHead() {
        if (TEST) {
            return HostUtil.TestHost.PRODUCT_HOST;
        } else {
            String value = SharePreferenceManager.getVaule(MoviesApplication.getInstance(), MoviesHttpApi.TEST_HOST, "");
            if (!TextUtils.isEmpty(value)) {
                return value;
            } else {
                return HostUtil.OnlineHost.PRODUCT_HOST;
            }
        }
    }

    public static String getNewAdStaticHead() {
        if (TEST) {
            return HostUtil.TestHost.PRODUCT_AD_HOST;
        } else {
            String value = SharePreferenceManager.getVaule(MoviesApplication.getInstance(), MoviesHttpApi.TEST_HOST, "");
            if (!TextUtils.isEmpty(value)) {
                return HostUtil.getAdHost(value);
            } else {
                return HostUtil.OnlineHost.PRODUCT_AD_HOST;
            }
        }
    }

    private static <T extends LVideoBaseBean, D> LVideoDataHull<T> request(
            LVideoHttpBaseParameter<T, D, ?> httpParameter) {
        LVideoHttpTool<T> handler = new LVideoHttpTool<T>();
        addHeaderAndSig(httpParameter);
        if (isCompleteUrl) {
            isCompleteUrl = false;
            return handler.requsetData(httpParameter, MoviesApplication.getInstance());
        }
        return handler.requsetData(httpParameter, MoviesApplication.getInstance());
    }

    private static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestNoParam(
            LVideoHttpBaseParameter<T, D, ?> httpParameter) {
        LVideoHttpTool<T> handler = new LVideoHttpTool<T>();
        if (isCompleteUrl) {
            isCompleteUrl = false;
            return handler.requsetData(httpParameter, MoviesApplication.getInstance());
        }
        return handler.requsetData(httpParameter, MoviesApplication.getInstance());
    }

    public static <T extends LVideoBaseBean, D> void addHeaderAndSig(LVideoHttpBaseParameter<T, D, ?> httpParameter) {
        LVideoRequestHeader header = new LVideoRequestHeader();
        header.setkToken(MoviesApplication.getInstance().getSharedPreferences(SettingManage.LOGIN_INFO, Context.MODE_PRIVATE).getString(LoginActivity.TOKEN, ""));
        header.setkUid(MoviesApplication.getInstance().getSharedPreferences(SettingManage.LOGIN_INFO, Context.MODE_PRIVATE).getString(LoginActivity.UID, ""));
        header.setkAppid(PLATFORM_IN_UPGRADE);
        header.setkMarket(MoviesUtils.getClientChannel());
        header.setkVersion(MoviesUtils.getClientVersionName());
        header.setkTeminal(PLATTYPE_VAULE);
        header.setkModel(MoviesUtils.getDeviceModel());
        header.setkScreen(MoviesUtils.getResolution(MoviesApplication.getInstance()));
        header.setkOS("Android " + MoviesUtils.getOSVersion());
        header.setkSdk(MoviesUtils.getMSdk());
        header.setkUuid(MoviesConstant.UUID);
        header.setkDc(MoviesUtils.getmDeviceId());
        header.setkAuid(BigDataConstants.AUID);
        httpParameter.setmHeader(header);

        if (httpParameter instanceof LVideoHttpParameter) {
            LVideoHttpParameter lVideoHttpParameter = (LVideoHttpParameter) httpParameter;
            if (lVideoHttpParameter.getParams() == null) {
                Bundle params = new Bundle();
                lVideoHttpParameter.setParams(params);
            }
            Bundle paramsBundle = (Bundle) lVideoHttpParameter.getParams();
            paramsBundle.putString(TS, String.valueOf(System.currentTimeMillis()));
            paramsBundle.putString(PUBLIC_PARAMETERS.API_VERSION, NEW_API_VERSION);
            String tags = PreferencesManager.getInstance().getTags();
            if (!TextUtils.isEmpty(tags)) {
                paramsBundle.putString(TAGS, tags);
            }
            paramsBundle.putString(SIG, SignChecker.getSign(paramsBundle));
        }
    }

    public static interface LeTvBitStreamParam {
        public String KEY_MMSID = "mid";
        public String KEY_PLS = "pls";
        public String KEY_TSS = "tss";
        public String KEY_CDETYPE = "cdetype";
        public String KEY_CDETYPE_TEST = "1";
        public String KEY_CDETYPE_AES = "2";
        public String KEY_LSSV = "lssv";
        public String KEY_REQUESTTYPE = "requesttype";
        public String KEY_DOWNLOAD = "download";
        public String KEY_PLAY = "play";
        public String KEY_CLOUD_CODE = "cloudcode";
        public String KEY_TYPE = "type";
        public String KEY_SRC = "src";
        public String KEY_VID = "vid";
    }

    /**
     * 请求指定站点的URL
     *
     * @param parser
     * @param url
     * @return zhangshuo 2014年6月13日 下午3:09:25
     */
    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestUrlAnalysis(
            LVideoBaseParser<T, D> parser, String url) {
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, null, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    private static final String REQUEST_PUSH_DATA = "push/kuaikanPush";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestPushData(
            LVideoBaseParser<T, D> parser) {
        Bundle params = new Bundle();
        String url = getPushHead() + REQUEST_PUSH_DATA;
        addCommonParams(params);
        params.putString("uuid", MoviesConstant.UUID);
        LogUtils.e("pushid", MoviesConstant.UUID);
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    public static String getPushHead() {
        if (TEST) {
            return MoviesConstant.TEST_PUSH_HOST;
        } else {
            return MoviesConstant.PRODUCT_PUSH_HOST;
        }
    }

    // public static <T extends LVideoBaseBean, D> LVideoDataHull<T>
    // requestCloudDiskData(
    // LVideoBaseParser<T, D> parser, String code, String type) {
    // Bundle params = new Bundle();
    // String url = "http://cloud.lvideo.com/ledisk/openapi/playurl";
    // params.putString("code", code);
    // params.putString("type", type);
    // params.putString("unique_id", MoviesConstant.UUID);
    // LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
    // url, params, LVideoHttpParameter.Type.GET, parser, -1);
    // return request(httpParameter);
    // }

    /**
     * 请求APP的配置接口(包含换量的配置)
     *
     * @param parser
     * @return zhangshuo 2014年10月13日 下午4:11:01
     */
    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestAppConfig(
            LVideoBaseParser<T, D> parser) {
        Bundle params = new Bundle();
        // proxy.le123.com
        // 123.126.32.90:8080
        String url = "http://proxy.le123.com/push/api/general";
        addCommonParams(params);
        params.putString("uuid", MoviesConstant.UUID);
        params.putString("auid", MoviesUtils.getPhoneImei());
        params.putString("mac", MoviesUtils.getMacAddress());
        params.putString("auid", MoviesUtils.getPhoneImei());
        params.putString("device_name", MoviesUtils.getDeviceModel());
        params.putString("device_os", MoviesUtils.getOSVersion());
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    /**
     * js截流
     *
     * @param parser
     * @param url
     * @return zhangshuo 2014年9月22日 上午11:23:38
     */
    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestHtmlData(
            LVideoBaseParser<T, D> parser, String url, String refererUrl,
            String userAgent) {
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, null, LVideoHttpParameter.Type.GET, parser, -1);
        httpParameter.setmReferer(refererUrl);
        if (!TextUtils.isEmpty(userAgent)) {
            httpParameter.setmUserAgent(userAgent);
        }
        httpParameter.setContentType("text/xml; charset=utf-8");
        LVideoHttpTool<T> handler = new LVideoHttpTool<T>();
        return handler.requsetData(httpParameter, MoviesApplication.getInstance());
    }

    public static final String URL_POST_SPREAD_DEVIDE_INFO = "SO-F/today/installersave";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> postSpreadDeviceInfo(
            LVideoBaseParser<T, D> parser) {
        Bundle params = new Bundle();
        String url = getLotteryStaticHead() + URL_POST_SPREAD_DEVIDE_INFO;

        params.putString("uuid", MoviesConstant.UUID);
        params.putString("platform", "aphone");
        params.putString("uuidr", UUIDFactory.getExternalStoredValue());
        params.putString(
                "device",
                Utils.getBrandName() + "_" + Utils.getModel() + "_"
                        + Utils.getSerialNumber());
        params.putString("os", Utils.getOSVersionName());
        params.putString("phone", MoviesConstant.SUBCHANNEL);
        params.putString("appfrom", CHANNEL);
        params.putString("packagename", MoviesConstant.PACKAGE_NAME);
        params.putString("signature", MoviesConstant.SIGNATURE);
        params.putString("version", VERSION);
        params.putString(
                "ck",
                MD5Utils.signByMD5(MoviesConstant.UUID
                        + MoviesConstant.SUBCHANNEL));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    public static final String URL_REQUEST_SPREAD_INFO = "draw/generalactivity";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestSpreadInfo(
            LVideoBaseParser<T, D> parser) {
        Bundle params = new Bundle();
        String url = getLotteryStaticHead() + URL_REQUEST_SPREAD_INFO;
        // if(MoviesConstant.DEBUG){
        // url = "http://123.126.32.90:8080/" + URL_REQUEST_SPREAD_INFO;
        // }
        String uuid = MoviesConstant.UUID + "_"
                + UUIDFactory.getExternalStoredValue();
        params.putString("uuid", uuid);
        params.putString("phone", MoviesConstant.SUBCHANNEL);
        params.putString("platform", PLATFORM);
        params.putString("ck", MD5Utils.signByMD5(uuid));
        params.putString("version", VERSION);
        params.putString(PUBLIC_PARAMETERS.LC, MoviesUtils.getmDeviceId());
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    public static final String URL_POST_SUBCHANNEL = "draw/packinstall";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> postSubChannel(
            LVideoBaseParser<T, D> parser) {
        Bundle params = new Bundle();
        String url = getLotteryStaticHead() + URL_POST_SUBCHANNEL;
        // if(MoviesConstant.DEBUG){
        // url = "http://123.126.32.90:8080/"+URL_POST_SUBCHANNEL;
        // }
        String uuid = MoviesConstant.UUID + "_"
                + UUIDFactory.getExternalStoredValue();
        params.putString("uuid", uuid);
        params.putString("phone", MoviesConstant.SUBCHANNEL);
        params.putString("platform", PLATFORM);
        params.putString("ck",
                MD5Utils.signByMD5(uuid + MoviesConstant.SUBCHANNEL));
        params.putString("version", VERSION);
        params.putString("device",
                MoviesConstant.BRAND + "_" + Utils.getModel() + "_"
                        + MoviesConstant.SERIAL_NUMBER);
        params.putString("os", Utils.getOSVersionName());
        params.putString("appfrom", CHANNEL);
        params.putString("packagename", MoviesConstant.PACKAGE_NAME);
        params.putString(PUBLIC_PARAMETERS.LC, MoviesUtils.getmDeviceId());
        LogUtils.d("subchannel", "post " + params.toString());
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    /**
     * 判断当前UTP是否存活的server
     */
    public static final String UTPSERVERURL = "http://127.0.0.1:6990/state/ok";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestUtpLiveServer(
            LVideoBaseParser<T, D> parser) {
        String url = UTPSERVERURL;
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, null, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    /**
     * 云盘流+乐视流(播放)
     *
     * @param parser
     * @param params
     * @param <T>
     * @param <D>
     * @return
     */
    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestLVideoStream(
            LVideoBaseParser<T, D> parser, Bundle params) {
        return request(getLVideoStreamParameter(parser, params));
    }

    /**
     * 乐视网码流参数
     *
     * @author zhangshuo
     */
    public static final String GET_STREAM_URL = "kuaikan/apijiexi_json.so";

    /**
     * 乐视源（包括网盘）请求下载和播放共用，拼串方法
     */
    public static <T extends LVideoBaseBean, D> LVideoHttpParameter<T, D> getLVideoStreamParameter(
            LVideoBaseParser<T, D> parser, Bundle params) {
        try {
            String url = getStaticHead() + GET_STREAM_URL;
//             String url = "http://106.38.226.221:7070/" + GET_STREAM_URL;
            addCommonParams(params);
            params.putString("uuid", MoviesConstant.UUID);
            params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
            String tssType;
            if (LeTvBitStreamParam.KEY_DOWNLOAD.equals(params
                    .getString(LeTvBitStreamParam.KEY_REQUESTTYPE))) {
                tssType = "no";
            } else {
                // 如果当前不使用系统硬解，则采用m3u8播放
                tssType = PlayDecodeMananger.ismNeedSysDecoder() ? "no" : "ios";
            }
            params.putString(LeTvBitStreamParam.KEY_TSS, tssType);
            // 获取lssv加密的值
            if (LeTvBitStreamParam.KEY_CDETYPE_AES.equals(params
                    .get(LeTvBitStreamParam.KEY_CDETYPE))) {
                // 执行AES256加密取得lssv字段的加密值
                StringBuilder sb = new StringBuilder(url);
                boolean first = true;
                for (String key : params.keySet()) {
                    if (first) {
                        sb.append("?");
                        first = false;
                    } else {
                        sb.append("&");
                    }
                    sb.append(key);
                    sb.append("=");
                    sb.append(params.getString(key));
                }
                LogUtils.e(TAG, "拼串----" + sb.toString());
                String lssv = Base64.encodeToString(
                        Utils.AES256_Encode(sb.toString()), Base64.DEFAULT);
                params.putString(LeTvBitStreamParam.KEY_LSSV, lssv);
            }
            params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                    MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
            LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                    url, params, LVideoHttpParameter.Type.GET, parser, -1);
            httpParameter.setUpdataId(APIJIEXI_TAG_1001);
            return httpParameter;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestSingleInfo(
            LVideoBaseParser<T, D> parser, String globalVid, String site,
            String src) {
        return request(getLVideoHttpParameter(parser, globalVid, site, src));
    }

    // 请求单机信息的URL
    public static final String SINGLE_INFO_URL = "kuaikan/apisingledetail_json.so";

    /**
     * 下载和播放共用，拼串方法 (外网SingleInfo)
     */
    public static <T extends LVideoBaseBean, D> LVideoHttpParameter<T, D> getLVideoHttpParameter(
            LVideoBaseParser<T, D> parser, String globalVid, String site,
            String src) {
        String url = getStaticHead() + SINGLE_INFO_URL;
        Bundle params = new Bundle();
        params.putString("soKey", globalVid);
        params.putString("subsrc", site);
        params.putString("src", src);
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return httpParameter;
    }

    /**
     * 请求直播列表的URL
     */
    private final static String LIVECHANNEL_INFO_URL = "kuaikan/apilivechannelaction_json.so";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestLiveChannelInfo(
            LVideoBaseParser<T, D> parser, Bundle params) {
        String url = getStaticHead() + LIVECHANNEL_INFO_URL;
        // String url = LIVECHANNEL_INFO_URL;
        params.putString("uuid", MoviesConstant.UUID);
        params.putString(PUBLIC_PARAMETERS.PLATFORM_KEY, PLATFORM);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        params.putString(PUBLIC_PARAMETERS.LC, MoviesUtils.getmDeviceId());
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    /**
     * 请求地域策略的URL
     */
    private final static String LOCATION_URL = "kuaikan/apilocation_json.so";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestLocationData(
            LVideoBaseParser<T, D> parser, String location) {
        // String url =
        // "http://115.182.93.104:7070/"+GET_MAINPAGE_RECOMMEND_DATA_URL;
        // String url = "http://10.135.28.87:7070/"+LOCATION_URL;
        String url = getStaticHead() + LOCATION_URL;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString("uuid", MoviesConstant.UUID);
        params.putString("location", location);
        LogUtils.e("", "Local Ip " + PreferencesManager.getInstance().getPublicIp());
        params.putString(PUBLIC_PARAMETERS.IP, PreferencesManager.getInstance().getPublicIp());
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }
    /**
     * 获取城市信息的URL
     */
    private final static String CITY_URL = "/api/v2/geo/city";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestCityInfo(
            LVideoBaseParser<T, D> parser, String mLatitude,String mLongitude,String province,String city,String county) {
        String url = getStaticHead() + CITY_URL;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString("uuid", MoviesConstant.UUID);
        params.putString("lat", mLatitude);
        params.putString("lon", mLongitude);
        params.putString("province", province);
        params.putString("city", city);
        params.putString("county", county);
        LogUtils.e("", "Local Ip " + PreferencesManager.getInstance().getPublicIp());
        params.putString(PUBLIC_PARAMETERS.IP, PreferencesManager.getInstance().getPublicIp());
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    private final static String LUAUNCH_DATA_URL = "kuaikan/apistart_json.so";

    /**
     * 启动图+启动广告图
     *
     * @param parser
     * @param city   eg:CN_1_5_1
     * @return
     */
    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestLaunchImageData(
            LVideoBaseParser<T, D> parser, String city) {
//        String url = "http://10.176.28.235:7070/" + LUAUNCH_DATA_URL;
        String url = getStaticHead() + LUAUNCH_DATA_URL;
        Bundle params = new Bundle();
        LogUtils.e("", "Local Ip " + PreferencesManager.getInstance().getPublicIp());
        params.putString(PUBLIC_PARAMETERS.IP, PreferencesManager.getInstance().getPublicIp());
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString("uuid", MoviesConstant.UUID);
        addCommonParams(params);
        params.putString(PUBLIC_PARAMETERS.LOCATION, city);
        params.putString("model", LAUNCH_MODEL);
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    private final static String AD_DATA_URL = "kuaikan/apiad_json.so";

    /**
     * 应用广告图
     *
     * @param parser
     * @param pageFrom
     * @return
     */
    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestAdData(
            LVideoBaseParser<T, D> parser, String pageFrom) {
//        String url = "http://106.38.226.221:7070/" + AD_DATA_URL;
        String url = getStaticHead() + AD_DATA_URL;
        Bundle params = new Bundle();
        LogUtils.e("", "Local Ip " + PreferencesManager.getInstance().getPublicIp());
        params.putString(PUBLIC_PARAMETERS.IP, PreferencesManager.getInstance().getPublicIp());
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString("uuid", MoviesConstant.UUID);
        addCommonParams(params);
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        params.putString("model", APP_MODEL);
        params.putString("whichpage", pageFrom);
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    private static String getLotteryStaticHead() {
        if (TEST) {
            return "http://123.126.32.90:8080/";
        }
        return "http://proxy.le123.com/";
    }

    private static void addCommonParams(Bundle params) {
        params.putString(PUBLIC_PARAMETERS.VERSION_KEY, VERSION);
        params.putString(PUBLIC_PARAMETERS.PLATFORM_KEY, PLATFORM);
        params.putString(PUBLIC_PARAMETERS.PLATTYPE_KEY, PLATTYPE_VAULE);
        params.putString(PUBLIC_PARAMETERS.LC, DEVICEID);
    }

    private static void addOnePointLogParams(Bundle params) {
        long timestamp = System.currentTimeMillis()/1000;
        String nonce = MoviesUtils.getRandomString(5);
        String secretkey = MoviesUtils.getSHA1(MoviesUtils.getMD5(MoviesConstant.ONEPOINT_SEXRETKEY)+nonce+String.valueOf(timestamp));
        params.putString("appid", MoviesConstant.ONEPOINT_APPID);
        params.putString("timestamp", String.valueOf(timestamp));
        params.putString("nonce", nonce);
        params.putString("secretkey", secretkey);
        params.putString("scode", "ysdaquan");
    }


    // 新外网截流
    public static final String API_STREAM_URL = "kuaikan/apistream_json.so";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestOutSiteStreamInfo(
            LVideoBaseParser<T, D> parser,
            String url, String formats, List<String> apicontent) {
        return request(getOutSiteStreamParameter(parser, url, formats, apicontent));
    }

    private static <T extends LVideoBaseBean, D> LVideoHttpParameter<T, D> getOutSiteStreamParameter(
            LVideoBaseParser<T, D> parser, String playUrl, String formats, List<String> apicontent) {
//        String url = "http://106.38.226.221:7070/" + API_STREAM_URL;
        String url = getStaticHead() + API_STREAM_URL;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString("url", playUrl);
        params.putString("formats", formats);
        LVideoHttpParameter<T, D> httpParameter;
        if (apicontent != null) {
            params.putString("extra_data", apicontent.get(0));
            httpParameter = new LVideoHttpParameter<T, D>(
                    url, params, LVideoHttpParameter.Type.POST, parser, -1);
            httpParameter.setContentType("application/x-www-form-urlencoded");
            httpParameter.setPostJsonData(httpParameter.encodeParam().toString());
            httpParameter.setParams(new Bundle());
        } else {
            httpParameter = new LVideoHttpParameter<T, D>(
                    url, params, LVideoHttpParameter.Type.GET, parser, -1);
        }
        return httpParameter;
    }

    public interface UpdateStreamParams {
        String URL = "url";
        String EID = "eid";
        String STATE = "state";
    }

    private static String UPDATE_STREAM = "kuaikan/apiupdatestream_json.so";

    /**
     * 外网播放，streamList地址无效调用update接口更新流
     *
     * @param parser
     * @param playUrl
     * @param eid
     * @param state
     * @param <T>
     * @param <D>
     * @return
     */
    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> updateStreamRequest(
            LVideoBaseParser<T, D> parser, String playUrl, String eid, int state) {
//        String url = "http://106.38.226.221:7070/" + UPDATE_STREAM;
        String url = getStaticHead() + UPDATE_STREAM;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString(UpdateStreamParams.URL, playUrl);
        params.putString(UpdateStreamParams.EID, eid);
        params.putString(UpdateStreamParams.STATE, String.valueOf(state));
        LogUtils.e(Utils.TAG, "##################updateStreamRequest params is " + params.toString());
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }


    public interface UpLoadLocalStreamParams {
        String ALLOW_FORMATS = "allow_formats";
        String REQUEST_FORMAT = "request_format";
        String OS_TYPE = "os_type";
        String STREAM_LIST = "stream_list";
        String URL = "url";
        String SEPARATOR = ",";
    }

    private static String UPLOAD_LOCAL_STREAM = "kuaikan/apiuploadlocalstream_json.so";

    /**
     * 本地js截流成功上报接口（外网播放，下载）
     *
     * @param parser
     * @param allow_formats
     * @param request_format
     * @param stream_list
     * @param osType
     * @param playUrl
     * @param <T>
     * @param <D>
     * @return
     */
    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> upLoadLocalStream(
            LVideoBaseParser<T, D> parser, List<String> allow_formats, String request_format, List<String> stream_list, String osType, String playUrl) {
//        String url = "http://106.38.226.221:7070/" + UPLOAD_LOCAL_STREAM;
        String url = getStaticHead() + UPLOAD_LOCAL_STREAM;
        Bundle params = new Bundle();
        params.putString(UpLoadLocalStreamParams.ALLOW_FORMATS, Utils.convertListToStr(allow_formats, UpLoadLocalStreamParams.SEPARATOR));
        params.putString(UpLoadLocalStreamParams.REQUEST_FORMAT, request_format);
        params.putString(UpLoadLocalStreamParams.OS_TYPE, osType);
        params.putString(UpLoadLocalStreamParams.STREAM_LIST, Utils.convertListToStr(stream_list, UpLoadLocalStreamParams.SEPARATOR));
        params.putString(UpLoadLocalStreamParams.URL, playUrl);
        params.putString(PUBLIC_PARAMETERS.LC, MoviesUtils.getmDeviceId());
        LogUtils.e(Utils.TAG, "******************upLoadLocalStream params is " + params.toString());
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    // js截流更新
//    private static final String GET_JSUPDATE_URL = "kuaikan/apiextractjs_json.so";
    private static final String GET_JSUPDATE_URL = "kuaikan/apiextractjsnew_json.so";

    public static String VER = "ver";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestJsUpdate(
            LVideoBaseParser<T, D> parser, String ver) {
        LogUtils.e(TAG, "requestJsUpdate");
        String url = getStaticHead() + GET_JSUPDATE_URL;
//        String url = "http://106.38.226.221:7070/" + GET_JSUPDATE_URL;
        Bundle params = new Bundle();
//        addCommonParams(params);
//        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString(VER, ver);
        params.putString(PUBLIC_PARAMETERS.LC, MoviesUtils.getmDeviceId());
//        params.putString("uuid", MoviesConstant.UUID);
        LogUtils.d("dyf", params.toString());
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestLiteAppLinkUrl(
            LVideoBaseParser<T, D> parser) {
        String url = "http://api.mob.app.letv.com/download";
//        String url = "http://t.api.mob.app.letv.com/download";
        Bundle params = new Bundle();
        params.putString("pcode", LiteAppManager.PCODE);
        params.putString("version", LiteAppManager.VERSION);
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    private static String REPORT_PICTURE = "kuaikan/apireport_submit.so";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> postReportPicture(
            LVideoBaseParser<T, D> parser, String pictureUrl, String aid, String uid, String contactPeople,
            String contactWay, String lawName) {
        String url = getStaticHead() + REPORT_PICTURE;
        Bundle params = new Bundle();
        if (!TextUtils.isEmpty(pictureUrl)) {
            params.putString("pictures", pictureUrl);
        }
        if (!TextUtils.isEmpty(aid)) {
            params.putString("aid", aid);
        }
        if (!TextUtils.isEmpty(contactPeople)) {
            params.putString("username", contactPeople);
        }
        if (!TextUtils.isEmpty(contactWay)) {
            params.putString("contactinfo", contactWay);
        }
        if (!TextUtils.isEmpty(lawName)) {
            params.putString("organization", lawName);
        }
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        if (!TextUtils.isEmpty(uid)) {
            params.putString("uid", uid);
        }
        LogUtils.e(Utils.TAG, "##################postReportPicture params is " + params.toString());
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.POST, parser, -1);
        return request(httpParameter);
    }


    private static String USER_FEEDBACK = "kuaikan/apireport_problem.so";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> postUserFeedback(
            LVideoBaseParser<T, D> parser, String scope, String aid, String description) {
        String url = getStaticHead() + USER_FEEDBACK;
        Bundle params = new Bundle();
        if (!"".equals(scope)) {
            params.putString("scope", scope);
        }
        if (!TextUtils.isEmpty(aid)) {
            params.putString("aid", aid);
        }
        if (!TextUtils.isEmpty(description)) {
            try {
                params.putString("description", URLEncoder.encode(description, "UTF-8"));
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LogUtils.e(Utils.TAG, "##################postUserFeedback params is " + params.toString());
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.POST, parser, -1);
        return request(httpParameter);
    }

    private static String USER_UPDATE = "kuaikan/apiuserupdate_json.so";

    public interface UserUpdateParams {
        String TOKEN = "token";
        String USER_NAME = "name";
        String USER_SEX = "gender";
        String USER_IMG = "photo";
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> userUpdateRequest(
            LVideoBaseParser<T, D> parser, String name, String gender, String photo) {
        String url = getStaticHead() + USER_UPDATE;
        Bundle params = new Bundle();
        if (!"".equals(name)) {
            params.putString(UserUpdateParams.USER_NAME, name);
        }
        if (!"".equals(gender)) {
            params.putString(UserUpdateParams.USER_SEX, gender);
        }
        if (!"".equals(photo)) {
            params.putString(UserUpdateParams.USER_IMG, photo);
        }
        LogUtils.e(Utils.TAG, "##################updateStreamRequest params is " + params.toString());
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    private static String USER_LOGIN = "kuaikan/apilogin_json.so";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> userLoginRequest(
            LVideoBaseParser<T, D> parser, String type, String name, String openId, String sex, String imgurl, String uid) {
        String url = getStaticHead() + USER_LOGIN;
        Bundle params = new Bundle();
        params.putString("type", type);
        params.putString("name", name);
        params.putString("openid", openId);
        params.putString("sex", sex);
        params.putString("imgurl", imgurl);
        params.putString("appid", USER_LOGIN_APPID);
        if (!TextUtils.isEmpty(uid)) {
            params.putString("uid",uid);
        }
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    private static String USER_MESSAGE = "kuaikan/apiuserinfo_json.so";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> userMessageRequest(
            LVideoBaseParser<T, D> parser, String token) {
        String url = getStaticHead() + USER_MESSAGE;
        Bundle params = new Bundle();
        LogUtils.e(Utils.TAG, "##################updateStreamRequest params is " + params.toString());
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    private static String LOGOUT = "kuaikan/apilogout_json.so";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> logoutRequest(
            LVideoBaseParser<T, D> parser, String token) {
        String url = getStaticHead() + LOGOUT;
        Bundle params = new Bundle();
        LogUtils.e(Utils.TAG, "##################updateStreamRequest params is " + params.toString());
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    /**
     * 获取收藏列表
     */
    public static String GET_FAVORITE_DATA = "kuaikan/apicollectionlist_json.so";

    public interface FavoriteDataParams {
        String START = "start";
        String LIMIT = "limit";
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> favoriteDataRequest(
            LVideoBaseParser<T, D> parser, int start, int limit) {
        String url = getStaticHead() + GET_FAVORITE_DATA;
        Bundle params = new Bundle();
        params.putString(FavoriteDataParams.START, start + "");
        params.putString(FavoriteDataParams.LIMIT, limit + "");
        LogUtils.e(Utils.TAG, "##################updateStreamRequest params is " + params.toString());
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    /**
     * 判断是否已经收藏
     */
    public static String IS_FAVORITE_SYNC = "kuaikan/apicheckcollection_json.so";

    public interface IsFavoriteSyncParams {
        String TOKEN = "token";
        String RELATEDID = "relatedid";
        String TYPE = "type";
    }

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> isfavoriteSyncRequest(
            LVideoBaseParser<T, D> parser, String relatedid, String type) {
        String url = getStaticHead() + IS_FAVORITE_SYNC;
        Bundle params = new Bundle();
        params.putString(IsFavoriteSyncParams.RELATEDID, relatedid);
        params.putString(IsFavoriteSyncParams.TYPE, type);
        LogUtils.e(Utils.TAG, "##################updateStreamRequest params is " + params.toString());
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    /**
     * 取消收藏
     */
    public static String REMOVE_FAVORITE = "kuaikan/apiremovecollection_json.so";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> removefavoriteRequest(
            LVideoBaseParser<T, D> parser, String relatedid, String type) {
        String url = getStaticHead() + REMOVE_FAVORITE;
        Bundle params = new Bundle();
        params.putString(IsFavoriteSyncParams.RELATEDID, relatedid);
        params.putString(IsFavoriteSyncParams.TYPE, type);
        LogUtils.e(Utils.TAG, "##################updateStreamRequest params is " + params.toString());
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.POST, parser, -1);
        return request(httpParameter);
    }

    /**
     * 添加收藏
     */
    public static String ADD_FAVORITE = "kuaikan/apiaddcollection_json.so";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> addfavoriteRequest(
            LVideoBaseParser<T, D> parser, String relatedid, String type, String source) {
        String url = getStaticHead() + ADD_FAVORITE;
        Bundle params = new Bundle();
        params.putString(IsFavoriteSyncParams.RELATEDID, relatedid);
        params.putString(IsFavoriteSyncParams.TYPE, type);
        params.putString("source", source);
        params.putString("productId", USER_PRODUCT_ID);
        LogUtils.e(Utils.TAG, "##################updateStreamRequest params is " + params.toString());
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.POST, parser, -1);
        return request(httpParameter);
    }

    /**
     * 批量上传收藏数据
     */
    private static String ADD_ALL_FAVORITE = "kuaikan/apibatchcollection_json.so";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> addAllfavoriteRequest(
            LVideoBaseParser<T, D> parser, List collection) {
        String url = getStaticHead() + ADD_ALL_FAVORITE;
        Bundle params = new Bundle();
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.POST, parser, -1);
        Gson gson = new Gson();
        httpParameter.setPostJsonData(gson.toJson(collection));
        return request(httpParameter);
    }


    public static String USER_PLAY_LIST = "kuaikan/apiplaylist_json.so";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> userPlayRecordRequest(
            LVideoBaseParser<T, D> parser, int index, int limit) {
        String url = getStaticHead() + USER_PLAY_LIST;
        Bundle params = new Bundle();
        params.putString("start", index + "");
        params.putString("limit", limit + "");
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    public static String DO_PLAY_RECORD = "kuaikan/apibatchplaylist_json.so";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> doPlayRecordRequst(
            LVideoBaseParser<T, D> parser, List<UploadPlayRecordBean> list) {
        String url = getStaticHead() + DO_PLAY_RECORD;
        Bundle params = new Bundle();
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.POST, parser, -1);
        Gson gson = new Gson();
        httpParameter.setPostJsonData(gson.toJson(list));
        return request(httpParameter);
    }

    public static String MAIN_INDEX_HEADER = "api/v2/index/header";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> mainHeaderRequst(
            LVideoBaseParser<T, D> parser) {
        String url = getStaticHead() + MAIN_INDEX_HEADER;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    //播放会话数据上报
    public static String REPORT_PLAY_SESSION = "report/play/session";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> reportPlaySession(
            LVideoBaseParser<T, D> parser, String dataString) {
        String url = getStaticHead() + REPORT_PLAY_SESSION;
        Bundle params = new Bundle();
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.POST, parser, -1);
        httpParameter.setPostJsonData(dataString);
        return request(httpParameter);
    }

    //播放结果数据上报
    public static String REPORT_PLAY_STATUS = "report/play/status";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> reportPlayStatus(
            LVideoBaseParser<T, D> parser, Bundle params) {
        String url = getStaticHead() + REPORT_PLAY_STATUS;
        if (params == null) {
            params = new Bundle();
        }
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.POST, parser, -1);
        return request(httpParameter);
    }

    //播放结果数据上报
    public static String REQUEST_HOME_PAGE = "api/v2/index/page";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestHomePageData(
            LVideoBaseParser<T, D> parser, String page) {
        String url = getStaticHead() + REQUEST_HOME_PAGE;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString(MAINPAGE_RECOMMEND_DATA_PARAMETERS.PAGE_KEY, page);
        params.putString("uuid", MoviesConstant.UUID);
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);

        return request(httpParameter);
    }

    //播放结果数据上报
    public static String REQUEST_FEED_MORE_PAGE = "api/v2/feed/more";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestMoreDataData(
            LVideoBaseParser<T, D> parser, String recid, String vt) {
        String url = getStaticHead() + REQUEST_FEED_MORE_PAGE;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString("recid", recid);
        params.putString("vt", vt);
        params.putString("uuid", MoviesConstant.UUID);
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);

        return request(httpParameter);
    }

    //推荐上报接口

    public static String REQUEST_REC_REPORT_PAGE = "api/v2/rec/report";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestRecReportData(
            LVideoBaseParser<T, D> parser, Bundle params) {
        String url = getStaticHead() + REQUEST_REC_REPORT_PAGE;

        addCommonParams(params);
        params.putString(PUBLIC_PARAMETERS.CODE_KEY, CODE);
        params.putString(PUBLIC_PARAMETERS.LOCATION, SharePreferenceManager.getVaule(
                MoviesApplication.getInstance(), MyLocationManager.LOCATIONKEY, ""));
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);

        return request(httpParameter);
    }
    // request init api
    private static final String APP_INIT = "api/v2/init";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestInit(LVideoBaseParser<T, D> parser) {
        String url = getStaticHead() + APP_INIT;
        Bundle params = new Bundle();
        params.putString(PUBLIC_PARAMETERS.PLATFORM_KEY, PLATFORM);
        String location = SharePreferenceManager.getVaule(MoviesApplication.getInstance(),
                SharePreferenceManager.LOCATION_LAT_LON, "");
        if (!TextUtils.isEmpty(location)) {
            params.putString("location", location);
        }
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(url, params,
                LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    // request Upgrade api
    private static final String APP_UPGRADE = "api/v2/upgrade";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestUpgrade(LVideoBaseParser<T, D> parser) {
        String url = getStaticHead() + APP_UPGRADE;
        Bundle params = new Bundle();
        params.putString(PUBLIC_PARAMETERS.PLATFORM_KEY, PLATFORM);
        String location = SharePreferenceManager.getVaule(MoviesApplication.getInstance(),
                SharePreferenceManager.LOCATION_LAT_LON, "");
        if (!TextUtils.isEmpty(location)) {
            params.putString("location", location);
        }
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(url, params,
                LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }
    // 请求风行sdk token
    private static final String GET_FS_TOKEN_URL = "/api/v2/misc/funshion_atoken";
    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestFsToken(LVideoBaseParser<T, D> parser) {
        String url = getStaticHead() + GET_FS_TOKEN_URL;
        Bundle params = new Bundle();
        addCommonParams(params);
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    //新版广告接口
    private static final String URL_REQUEST_HZ_AD = "api/v1/ad/get";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestHzAd(
            LVideoBaseParser<T, D> parser, Bundle params) {
        String url = getNewAdStaticHead() + URL_REQUEST_HZ_AD;
        addCommonParams(params);
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    //第三方ad上报
    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> reportThirdAd(
            LVideoBaseParser<T, D> parser, String reportUrl, String userAgent) {
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                reportUrl, new Bundle(), LVideoHttpParameter.Type.GET, parser, -1);
        if(!TextUtils.isEmpty(userAgent)){
            httpParameter.setmUserAgent(userAgent);
        }
        return requestNoParam(httpParameter);
    }

    //data
    public static String NEW_DATA_REPORT_URL = HostUtil.OnlineHost.DATA_REPORT_URL;

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> reportSelfData(
            LVideoBaseParser<T, D> parser, List list) {
        String value = SharePreferenceManager.getVaule(MoviesApplication.getInstance(), MoviesHttpApi.TEST_HOST, "");
        String url = HostUtil.getDataReportHost(value);
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, new Bundle(), LVideoHttpParameter.Type.POST, parser, -1);
        httpParameter.setContentType("application/json");
        httpParameter.setPostJsonData(new JSONArray(list).toString());
        return request(httpParameter);
    }
    //data
    public static String ONE_POINT_REPORT_URL = "http://o.go2yd.com/open-api/yddaquan/real_time_log";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> onePointReport(
            LVideoBaseParser<T, D> parser, JSONObject jsonObject) {
        String value = SharePreferenceManager.getVaule(MoviesApplication.getInstance(), MoviesHttpApi.TEST_HOST, "");
        String url = ONE_POINT_REPORT_URL;
        Bundle params = new Bundle();
        try {
            String userid=jsonObject.getString("userid");
            if (!TextUtils.isEmpty(userid)){
                params.putString("userid",userid);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addOnePointLogParams(params);

        JSONObject total = new JSONObject();
        try {
            jsonObject.put("appid",MoviesConstant.ONEPOINT_APPID);
//            jsonObject.put("type","CLICK");
//            jsonObject.put("subType","enterFeeds");
            jsonObject.put("date",Utils.getCurrentTimeByPattern("yyyy-MM-dd HH:mm:ss"));
            jsonObject.put("bundle_version",VERSION);
            jsonObject.put("device_name",MoviesUtils.getDeviceModel());
            jsonObject.put("log_id", UUID.randomUUID().toString());
            jsonObject.put("device_id",BigDataConstants.DEVICEID);
            total.put("log",jsonObject);


        } catch (JSONException e) {
            e.printStackTrace();
        }
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.POST, parser, -1);
        httpParameter.setContentType("application/json");
        httpParameter.setPostJsonData(total.toString());
        return request(httpParameter);
    }

    // 反馈问题列表
    private static final String GET_FEEDBACK_QUESTION_URL = "api/v2/feedback/category";
    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestFeedbackQuestion(LVideoBaseParser<T, D> parser) {
        String url = getStaticHead() + GET_FEEDBACK_QUESTION_URL;
        Bundle params = new Bundle();
        addCommonParams(params);
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }

    // 反馈问题提交
    private static final String FEEDBACK_QUESTION_REPORT_URL = "api/v2/feedback/report";
    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestFeedbackQuestionSubmit(LVideoBaseParser<T, D> parser, String aid, String site, String city,
                                                                                                String scope, String subscope, String description, String contact) {
        String url = getStaticHead() + FEEDBACK_QUESTION_REPORT_URL;
        Bundle params = new Bundle();
        addCommonParams(params);
        params.putString("aid", aid);
        params.putString("site", site);
        params.putString("city", city);
        params.putString("scope", scope);
        params.putString("subscope", subscope);
        params.putString("desc", description);
        params.putString("contact", contact);
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.POST, parser, -1);
        return request(httpParameter);
    }

    //一点资讯列表接口
    private static final String URL_ONEPOINT_LIST = "api/v2/recommend_channel_list";

    public static <T extends LVideoBaseBean, D> LVideoDataHull<T> requestOnePointList(
            LVideoBaseParser<T, D> parser, Bundle params) {
        String url = getStaticHead() + URL_ONEPOINT_LIST;
        LVideoHttpParameter<T, D> httpParameter = new LVideoHttpParameter<T, D>(
                url, params, LVideoHttpParameter.Type.GET, parser, -1);
        return request(httpParameter);
    }
}
